# _*_ encoding:utf-8 _*_
from __future__ import unicode_literals
from datetime import datetime
from django.db import models
from DjangoUeditor.models import UEditorField

# Create your models here.
class MachinePO(models.Model):
    """
    机台标识
    """

    booleanField = models.BooleanField(default=True, verbose_name=u"是否启用")

    ip_address = models.CharField(max_length=150, verbose_name=u"ip_address", default="")
    name = models.CharField(max_length=150, verbose_name=u"机床机台名称(现场设备上贴的机台号)", default="")
    machineID = models.CharField(max_length=150, verbose_name=u"机台 ID", default="", blank=True)

    remark = models.CharField(max_length=50, verbose_name=u"备注", default="", blank=True)
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name=u"修改时间")

    class Meta:
        verbose_name = u"机台标识"
        verbose_name_plural = verbose_name
        db_table = 'machinePO'

    def __str__(self):
        return self.name


class DebugLogPO(models.Model):
    """
    调试记录
    """

    booleanField = models.BooleanField(default=False, verbose_name=u"是否解决")

    name = models.ForeignKey(MachinePO, verbose_name=u"机床机台名称(现场设备上贴的机台号)", on_delete=models.CASCADE)

    problem_description = models.Content = UEditorField(verbose_name=u"问题详情", width=1300, height=300, imagePath="debuglog/ueditor/",
                                            filePath="debuglog/ueditor/", default="")

    remark = models.CharField(max_length=50, verbose_name=u"备注", default="", blank=True)
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name=u"修改时间")

    class Meta:
        verbose_name = u"调试记录"
        verbose_name_plural = verbose_name
        db_table = 'DebugLogPO'

    def __str__(self):
        return self.name.name